<!DOCTYPE HTML>
<%@page import="java.util.Iterator"%>
<%@page import="shop.vo.AddressBean"%>
<%@page import="java.util.List"%>
<%@page import="shop.factory.DAOFactory"%>
<%@page import="shop.vo.UserBean"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<meta charset="UTF-8" />
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/address.css" />
<script src="../js/jquery-1.10.2.min.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<title>配送地址</title>
<style type="text/css">
.page-header {
	margin-top: 10px;
}
</style>
</head>
<%
	String str = (String)session.getAttribute("user");
	UserBean user = new UserBean();
	user.setUser_name(str);
	int id = DAOFactory.getIUserDAOInstance().findId(user);
	List<AddressBean> list = DAOFactory.getIAddressDAOInstance().findAddr(id);
	Iterator<AddressBean> it = list.iterator();
%>
<body>
	<nav class="navbar navbar-default" role="navigation">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
		</div>
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li class="active"><a href="../index.jsp">首页</a></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyOrder"> <img src="../images/order.png" /> 我的订单
				</a></li>
				<li></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyCart"> <img src="../images/car.png" /> 我的购物车
				</a></li>
				<li><a href="<%=request.getContextPath() %>/FavoriteServlet?action=MyFav"> <img src="../images/favorite.png" /> 我的收藏
				</a></li>
				<li><a href="<%=request.getContextPath() %>/AddressServlet?action=MyAddress"> <img src="../images/address.png" /> 我的地址簿
				</a></li>
			</ul>

			<ul class="nav navbar-nav navbar-right">
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=xinxi"><span id="huanying">欢迎光临，游客</span></a></li>
				<li><a href="../Login/login.jsp">登陆</a></li>
				<li><a href="../Login/regist.jsp">注册</a></li>
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=logout" class="active" onclick="return confirm('确认退出?')">退出</a></li>
			</ul>
		</div>
	</nav>

	<div class="container" style="height: 468px;">
		<div class="col-md-4">
			<img src="../images/logo.png" />
		</div>
		<div class="col-lg-12">
			<h2>配送到以下地址：</h2>
			<a href="<%=request.getContextPath() %>/AddressServlet?action=addAddr" class="btn btn-primary">添加新地址</a>
			<div class="page-header"></div>
			<div class="table-responsive">
				<form action="<%=request.getContextPath() %>/OrderServlet" method="post" name="goaddress"
					onsubmit="return checknumber()">
					<table class="table">
						<thead>
							<tr>
								<th>选项</th>
								<th>姓名</th>
								<th>地址</th>
								<th>电话</th>
								<th>邮政编码</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<%
								while (it.hasNext()) {
									AddressBean addr = it.next();
							%>
							<tr class="danger">
								<td><input type="radio" name="checked" class="check"
									value="<%=addr.getAddr_id() %>" /></td>
								<td><%=str %></td>
								<td><%=addr.getAddr_address() %></td>
								<td><%=addr.getAddr_mobile() %></td>
								<td><%=addr.getAddr_zip() %></td>
								<td><a href="<%=request.getContextPath()%>/AddressServlet?action=xiugai&id=<%=addr.getAddr_id()%>">修改地址</a> <br>
								<a href="<%=request.getContextPath()%>/AddressServlet?action=delete"">删除</a></td>
							</tr>
							<%
								}
							%>
						</tbody>
					</table>
					<input type="submit" value="确认订单" class="btn btn-success" />
					<input type="hidden" name="action" value="createOrder">
				</form>
			</div>
		</div>
	</div>

	<div class="container-fluid foot-bg">
		<p>Power by Liang&Luo @版本号V0.0.01</p>
	</div>
</body>
<script type="text/javascript">
<%
	String str0 = (String)session.getAttribute("user");
	if (session.getAttribute("user") != null) {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，<%=str0%>";
<%
	} else {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，游客";
<%
	}
%>
</script>
</html>